#ifndef __DOUBLELINKLIST_H__
#define __DOUBLELINKLIST_H__


#define ElementType void*
struct Node
{
    ElementType data;
    struct Node *prev;
    struct Node *next;
};
typedef struct DBLinkList
{
    struct Node *head;
    struct Node *tail;
    int len;
}DBL;

extern int InitDBLinkList(DBL *list);
extern struct Node* CreateNode(ElementType element);
extern void DBInsertTail(DBL *list,ElementType element);
extern void FreeDBLList(DBL *list);
extern void DBTravel(DBL *list,void (*func)(ElementType,DBL *),DBL* GameUserData);
extern void DBInsertHead(DBL *list,ElementType element);
extern void InsertByIndex(DBL *list,ElementType element,int index);
extern void DBRemoveByIndex(DBL *list,int index);

int FindFirstByElement(DBL *list,ElementType element);
extern void DBRemoveByElement(DBL *list,ElementType element);

extern ElementType *DBFindByIndex(DBL *list,int index);
extern int *DBFindByElement(DBL *list,ElementType element);
extern void DBSetValueByIndex(DBL *list,int index,ElementType element);
extern void DBSetValueByElement(DBL *list,ElementType old_element,ElementType new_element);

extern void BubbleSort(DBL *list);

#endif